package com.czm.art_light.controller;

import com.czm.art_light.constant.ApiRouterConsts;
import com.czm.art_light.constant.ArtErrorCodeEnum;
import com.czm.art_light.param.request.ArtUserLikesReqDto;
import com.czm.art_light.param.request.PageReqDto;
import com.czm.art_light.param.response.ArtWorkBasicInfoRespDto;
import com.czm.art_light.param.response.PageRespDto;
import com.czm.art_light.param.response.RestResp;
import com.czm.art_light.service.ArtUserLikesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户爱好信息 API 控制器
 */
@Tag(name = "用户爱好管理",description = "用户爱好管理相关接口")
@RestController
@RequestMapping(ApiRouterConsts.LIKE_API_URL_PREFIX)
public class ArtUserLikesController {
    @Autowired
    private ArtUserLikesService artUserLikesService;

    /**
     * 修改喜好的状态
     */
    @Operation(summary = "修改喜好的状态")
    @PostMapping ("/update/status")
    public RestResp<Void> updateUserLikeStatus(@RequestBody ArtUserLikesReqDto artUserLikesReqDto) {
        // 校验参数
        if (artUserLikesReqDto == null) {
            return RestResp.fail(ArtErrorCodeEnum.USER_INVALID_PARAM);
        }
        // 调用 service 进行修改喜好的状态并返回结果
        return artUserLikesService.updateUserLikeStatus(artUserLikesReqDto);
    }

    /**
     * 查询用户喜爱的所有艺术画作品
     */
    @Operation(summary = "查询用户喜爱的所有艺术画作品")
    @PostMapping("/getUserLinksArtWork")
    public RestResp<PageRespDto<ArtWorkBasicInfoRespDto>> getUserLinksArtWork(@Valid @RequestBody PageReqDto pageReqDto){
        PageRespDto<ArtWorkBasicInfoRespDto> pageRespDto = artUserLikesService.getUserLinksArtWork(pageReqDto);
        return RestResp.ok(pageRespDto);
    }
}
